package org.twdata.pipeline;

import java.net.URL;

import java.util.HashMap;
import javax.xml.transform.Source;
import javax.xml.transform.Result;

/**
 *  Stores context information for particular run of the XML pipeline.
 */
public class PipelineContext extends HashMap {

    /**  Key under which a source resolver is stored */
    public final static String SOURCE_RESOLVER = "sourceResolver";
    /**  Key under which the source, if applicable, is stored */
    public final static String SOURCE = "source";
    /**  Key under which the result, if applicable, is stored */
    public final static String RESULT = "result";

    public PipelineContext() {
        super();
    }
    
    public PipelineContext(Source source, Result result) {
        super();
        setSource(source);
        setResult(result);
    }

    /**
     *  Sets the SourceResolver in the context
     *
     *@param  resolver  The new SourceResolver
     */
    public void setSourceResolver(SourceResolver resolver) {
        put(SOURCE_RESOLVER, resolver);
    }


    /**
     *  Gets the SourceResolver from the context
     *
     *@return    The SourceResolver value
     */
    public SourceResolver getSourceResolver() {
        return (SourceResolver)get(SOURCE_RESOLVER);
    }


    /**
     *  Sets the source in the context
     *
     *@param  source  The new source  
     */
    public void setSource(Source source) {
        put(SOURCE, source);
    }


    /**
     *  Gets the source from the context
     *
     *@return    The source value
     */
    public Source getSource() {
        return (Source)get(SOURCE);
    }
    
    /**
     *  Sets the result in the context
     *
     *@param  result  The new result  
     */
    public void setResult(Result result) {
        put(RESULT, result);
    }


    /**
     *  Gets the result from the context
     *
     *@return    The result value
     */
    public Result getResult() {
        return (Result)get(RESULT);
    }
}

